﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;



using Meqs.Entity;
using Meqs.Entity.Views;
using Meqs.Logic.Interface;

namespace Meqs.Logic.Implement
{
    public class StuCausePersonCatchLogic : CommonLogic<StuCausePersonCatch, int>, IStuCausePersonCatchLogic
    {
        #region Implementation of ICommonLogic<StuCausePersonCatch, int>

        /// <sammury>
        /// 创建对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(StuCausePersonCatch entity)
        {
            return CreateObject(entity);
        }

        /// <sammury>
        /// 更新对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(StuCausePersonCatch entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public StuCausePersonCatch FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount()
        {
            return FindObjectByCount();
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<StuCausePersonCatch> FindAll()
        {
            return FindAllObject();
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<StuCausePersonCatch> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion

        #region Implementation of IStuCausePersonCatchLogic

        /// <summary>
        /// 插入记录
        /// </summary>
        /// <param name="mpc"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public int InsertStuCausePersonCatch(StuCausePersonCatch mpc, string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("StuCausePersonCatch", mpc);
            ht.Add("SchoolMark", schoolMark);
            return (int)InsertCustomer("StuCausePersonCatch.InsertStuCausePersonCatch", ht);
        }

        /// <summary>
        /// 删除缓存表中对应单据及学生的记录
        /// </summary>
        /// <param name="studentID"></param>
        /// <param name="recordID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public int DeleteStuCausePersonCatch(int studentID, int recordID, string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("StudentID", studentID);
            ht.Add("RecordID", recordID);
            ht.Add("SchoolMark", schoolMark);
            return DeleteCustomer("StuCausePersonCatch.DeleteStuCausePersonCatch", ht);
        }


        /// <summary>
        /// 获取学分查询记录
        /// </summary>
        /// <param name="schoolMark"></param>
        /// <param name="grade"></param>
        /// <param name="clsId"></param>
        /// <param name="schoolYear"></param>
        /// <param name="term"></param>
        /// <returns></returns>
        public IList<CreditReport> GetCreditReport(string schoolMark, int grade, int clsId, int schoolYear, int term)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", schoolMark);
            table.Add("SchoolYear", schoolYear);
            table.Add("Term", term);
            table.Add("Grade", grade);
            table.Add("ClsID", clsId);

            return FindCustomer<CreditReport>("StuCausePersonCatch.GetCreditReport", table);
        }


        /// <summary>
        /// 获取学分查询记录，查询学分最终结果
        /// </summary>
        /// <param name="schoolMark"></param>
        /// <param name="grade"></param>
        /// <param name="clsId"></param>
        /// <param name="schoolYear"></param>
        /// <param name="term"></param>
        /// <returns></returns>
        public IList<CreditReportView> GetCreditReportView(string schoolMark, int grade, int schoolYear, int term, int causeId)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", schoolMark);
            table.Add("SchoolYear", schoolYear);
            table.Add("Term", term);
            table.Add("Grade", grade);
            table.Add("CauseID", causeId);

            return FindCustomer<CreditReportView>("StuCausePersonCatch.GetCreditReportView", table);
        }

        public IList<CreditReport> GetCreditByMonth(String schoolMark, int clsID, int schoolYear, int term, DateTime startDate, DateTime endDate)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", schoolMark);
            table.Add("SchoolYear", schoolYear);
            table.Add("Term", term);
            table.Add("StartDate", startDate.ToString("yyyy-MM-dd"));
            table.Add("EndDate", endDate.ToString("yyyy-MM-dd"));
            table.Add("ClsID", clsID);

            return FindCustomer<CreditReport>("StuCausePersonCatch.GetCreditByMonth", table);
        }

        /// <summary>
        /// 学生成长档案
        /// </summary>
        /// <param name="schoolMark"></param>
        /// <param name="stuID"></param>
        /// <returns></returns>
        public IList<CreditHistory> GetStudentHistoryReport(string schoolMark, int stuID)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", schoolMark);
            table.Add("StuID", stuID);

            return FindCustomer<CreditHistory>("StuCausePersonCatch.GetCreditHistoryReport", table);
        }

        #endregion

        /// <summary>
        /// 毕业学生各科学分
        /// </summary>
        public IList<GraduationScore> GetGraduationScore(string schoolMark, int clsID)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", schoolMark);
            table.Add("ClsID", clsID);
            return FindCustomer<GraduationScore>("StuCausePersonCatch.GetGraduationScore", table);
        }

        ///// <summary>
        ///// 毕业德育学分
        ///// </summary>
        //IList<GraduationScore> GetGraduationTestScore(string schoolMark, int clsID)
        //{
        //    Hashtable table = new Hashtable();
        //    table.Add("SchoolMark", schoolMark);
        //    table.Add("ClsID", clsID);
        //    return FindCustomer<GraduationScore>("StuCausePersonCatch.GetGraduationTestScore", table);
        //}
    }
}